home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-25 | 2.2 KB | 102 lines | [TEXT/CWIE] |
- /*
- File: MoreWindows.cp
-
- Contains:
-
- Written by: Pete Gontier (PCG)
-
- Copyright: Copyright (c) 1998 Apple Computer, Inc.
-
- Change History (most recent first):
-
- <2> 7/24/98 PCG eliminate dependency on 'qd'
- <1> 6/16/98 PCG initial checkin
- */
-
-
- #include "MoreQuickDraw.h"
- #include "MoreWindows.h"
- #include "MoreAppearance.h"
-
- #include <Controls.h>
- #include <Menus.h>
-
- pascal OSStatus MoveWindowToAlertPosition (WindowRef window)
- {
- OSStatus err = noErr;
-
- if (!MoreAssert (HaveAppearance ( ) || IsWindowVisible (window)))
- err = paramErr;
- else
- {
- Rect screenRect = (**GetMainDevice ( )).gdRect;
- screenRect.top += GetMBarHeight ( );
- InsetRect (&screenRect,4,4);
-
- Rect contRect;
-
- if (!HaveAppearance ( ) || IsWindowVisible (window))
- contRect = (**(((WindowPeek)window)->contRgn)).rgnBBox;
- else
- {
- RgnHandle contRgn = NewRgn ( );
-
- if (!contRgn)
- err = QDError ( );
- else
- {
- err = GetWindowRegion (window,kWindowContentRgn,contRgn);
-
- contRect = (**contRgn).rgnBBox;
-
- DisposeRgn (contRgn);
- (void) MoreAssert (noErr == QDError ( ));
- }
- }
-
- if (!err)
- {
- Point windLoc;
-
- windLoc.v = screenRect.top + ((screenRect.bottom - screenRect.top) / 3);
- windLoc.h = screenRect.left + ((screenRect.right - screenRect.top) / 2);
-
- windLoc.v -= (contRect.bottom - contRect.top) / 2;
- windLoc.h -= (contRect.right - contRect.left) / 2;
-
- MoveWindow (window, windLoc.h, windLoc.v, true);
- }
- }
-
- return err;
- }
-
- pascal OSErr MoreNewWindow ( const Rect * boundsRect,
- ConstStr255Param title,
- short theProc,
- Boolean goAwayFlag,
- long refCon,
- WindowRef *window )
- {
- OSErr err = noErr;
-
- if (!title)
- title = "\p";
-
- if (HaveColorQuickDraw ( ))
- *window = NewCWindow (nil,boundsRect,title,false,theProc,(WindowRef)kFirstWindowOfClass,goAwayFlag,refCon);
- else
- *window = NewWindow (nil,boundsRect,title,false,theProc,(WindowRef)kFirstWindowOfClass,goAwayFlag,refCon);
-
- if (!*window)
- err = nilHandleErr;
- else if (HaveAppearance ( ))
- {
- ControlRef dontCare;
- err = CreateRootControl (*window,&dontCare);
- if (err) DisposeWindow (*window);
- }
-
- return err;
- }
-